
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.ArrayList;
import java.io.*;

class ComplexTypeDeclaration extends Node {
	private Node type_;
	private String name_;
	private Node block_;
	private String ename_;
        private List<Node> children;

	public ComplexTypeDeclaration(Node t, String n, Node b, String en) {
		type_ = t;
		name_ = n;
		block_ = b;
		ename_ = en;
                children = new ArrayList<Node>();
                children.add(type_);
		children.add(new StringNode(name_));
		children.add(new StringNode("extends"));
		children.add(new StringNode(en));
                children.add(block_);
	}

	public ComplexTypeDeclaration(Node t, String n, Node b) {
		type_ = t;
		name_ = n;
		block_ = b;
		children = new ArrayList<Node>();
		children.add(type_);
		children.add(new StringNode(name_));
		children.add(block_);
	}
	
	
	public void print(PrintWriter pw) {
		pw.println("Node name : ComplexTypeDeclaration. Class name is: "
				+ name_);
		// assert(type_ && block_);
		type_.print(pw);
		if (ename_ != null) {
			pw.println("Extends Class name is: " + ename_);
		}
		block_.print(pw);
	}

	public String translate(PrintWriter pw,String condition) {
//		if (ename_ == null) {
//			pw.print("public class " + name_ + " ");
//		} else {
//			pw.print("public class " + name_ + "extends " + ename_ + " ");
//		}
		
//		PrintWriter ast_pw;
//		try {
//			ast_pw = new PrintWriter("Test9.out");
//			ast_pw.print( "Test" );
//			ast_pw.close();
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		type_.translate(pw,null);		
		pw.print("public class " + name_ + " " );
		block_.translate(pw,null);	
		return null;
	}

}
